﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Data.SQLite;
using System.IO;
namespace chessLogic
{
    public class DBDriver
    {
        public SQLiteConnection connect;
        public SQLiteCommand command;
        public SQLiteDataAdapter adapter;

        public DBDriver()
        {
            this.connect = new SQLiteConnection(@"Data source=D:\SUSU\Vinokur\chessLib\chessLogic\chessLogic\Date\chess.db;");
        }
        public void OpenConnect()
        {
            this.connect.Open();
        }
        public void CloseConnect()
        {
            this.connect.Close();
        }
        public bool IsConnectOpen()
        {
            if (this.connect.State == ConnectionState.Open)
                return true;
            return false;
        }
        public DataTable GetData(string query)
        {
            DataTable dataTable = new DataTable();
            this.command = new SQLiteCommand(query, this.connect);
            this.adapter = new SQLiteDataAdapter(this.command);
            this.adapter.Fill(dataTable);
            return dataTable;
        }
    }
}